********************************************************************************
* Institutional overlap and the survival of intergovernmental organizations
********************************************************************************

* Dynamic analysis
********************************************************************************

* Data and variables

  use "WEP_replication_IGO-years", clear
   
  g t=year-strt_yr
  g t2=t^2-t
  g t3=t^3-3*t

  g surv1=1-dead_clean
  lab var surv1 "IGO survived"
  g surv2=1-death
  lab var surv2 "IGO survived (COW variable)"
  
  g period=0
  forvalues k=1/7{
   replace period=`k' if (strt_yr>=1945+10*(`k'-1) & strt_yr<=1954+10*(`k'-1))
   }
  replace period=7 if strt_yr>=2014

  g lngdp_mean=ln(nygdpmktpcd_mean)
  g lngdp_sd=ln(nygdpmktpcd_sd)
  g lnni=ln(nmem)
  
  qui xi:reg strt_yr i.region i.period
  global IA issue_*
  xtset id_figo year
  

* Descriptive statistics 

  qui estpost su surv1 surv2 GI GIany GIno lnni secretariat_ind us_mem initsharedG7 initMGI nover_live nover_dead idealpoint_mean idealpoint_sd polity2_mean polity2_sd lngdp_mean lngdp_sd
  
** Table A1  
esttab ., cells("count(fmt(0)) mean(fmt(3)) sd(fmt(3)) min(fmt(3)) max(fmt(3))")


* Analysis

  ** Main model **
  qui probit surv1 GI _Iregion* _Iperiod* t*, vce(cl id_figo)
  est store b11
  qui probit surv1 GI $IA _Iregion* _Iperiod* t*, vce(cl id_figo)
  est store b12
  qui probit surv1 GI lnni $IA _Ireg* _Iperiod* t*, vce(cl id_figo)
  est store b13
  qui probit surv1 GI lnni secretariat_ind $IA _Ireg* _Iperiod* t*, vce(cl id_figo)
  est store b14

** Table 3  
estout b1*, title("Probit regression with clustered standard errors") note("p-values: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_* t*) stat(N N_clust r2_p, fmt(0 0 3)) 

  
  ** Disaggregating context **
  qui probit surv1 GIany GIno _Iregion* _Iperiod* t*, vce(cl id_figo)
  est store b21 
  qui probit surv1 GIany GIno $IA _Iregion* _Iperiod* t*, vce(cl id_figo)
  est store b22
  qui probit surv1 GIany GIno lnni $IA _Iregion* _Iperiod* t*, vce(cl id_figo)
  est store b23 
  qui probit surv1 GIany GIno lnni secretariat_ind $IA _Iregion* _Iperiod* t*, vce(cl id_figo)
  est store b24 
  
** Table 4  
estout b2*, title("Probit regression with clustered standard errors") note("p-values: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_* issue* t*) stat(N N_clust r2_p, fmt(0 0 3)) 


* Robustness

  ** Additional controls 
  qui probit surv1 GIany GIno us_member $IA _Iregion* _Iperiod* t*, vce(cl id_figo)
  est store b31 
  qui probit surv1 GIany GIno us_member initsharedG7 initMGI $IA _Iregion* _Iperiod* t*, vce(cl id_figo)
  est store b32
  qui probit surv1 GIany GIno us_member initsharedG7 initMGI nover_live nover_dead $IA _Iregion* _Iperiod* t*, vce(cl id_figo)
  est store b33 
  qui probit surv1 GIany GIno us_member initsharedG7 initMGI nover_live nover_dead idealpoint_mean idealpoint_sd polity2_mean polity2_sd $IA _Iregion* _Iperiod* t*, vce(cl id_figo)
  est store b34 
  qui probit surv1 GIany GIno us_member initsharedG7 initMGI nover_live nover_dead idealpoint_mean idealpoint_sd polity2_mean polity2_sd lngdp_mean lngdp_sd $IA _Iregion* _Iperiod* t*, vce(cl id_figo)
  est store b35
  
** Table A3   
estout b3*, title("Probit regression with clustered standard errors") note("p-values: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_* issue* t*) stat(N N_clust r2_p, fmt(0 0 3))   

   
  ** Alternative estimator **
  qui reghdfe surv1 GI t*, a(id_figo) cl(id_figo)
  est store b41
  qui reghdfe surv1 GI lnni t*, a(id_figo) cl(id_figo)
  est store b42
  qui reghdfe surv1 GIany GIno t*, a(id_figo) cl(id_figo)
  est store b43
  qui reghdfe surv1 GIany GIno lnni t*, a(id_figo) cl(id_figo)
  est store b44

** Table A4   
estout b4*, title("Linear regression with clustered standard errors") note("p-values: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_* t*) stat(N N_clust r2_a, fmt(0 0 3))   
  

  ** Scope expansion **  
  di "probit surv1 GI scope _Iregion* _Iperiod* t*, vce(cl id_figo) difficult iterate(40)"
  di "---Does not converge" 

  preserve
    g s_exp=d.scope>0 if scope!=.
    g s_dec=d.scope<0 if scope!=.
    g lifespan=end_yr-strt_yr
    collapse (mean)lifespan GI (sum)s_exp s_dec, by(id_figo)

	** Figure A3
    twoway (scatter lifespan GI) (lfit lifespan GI) if s_exp>0, scheme(s1mono) xtitle(Functional overlap) ytitle(Lifespan) legend(off)
    twoway (scatter lifespan GI) (lfit lifespan GI) if s_exp==0, scheme(s1mono) xtitle(Functional overlap) ytitle(Lifespan) legend(off)

  restore

  

* Cross-sectional analysis
********************************************************************************

* Data and variables

  use "WEP_replication_IGOs", clear
    
  g surv1=1-dead_clean
  lab var surv1 "IGO survival"
  g surv2=1-death 
  lab var surv2 "IGO survival (COW variable)"

  g anyzombie=zombie>0 if zombie!=.
  g MAJPOW=majpow_ij>=0.411
  g G7=g7_ij>=0.2585

  global IA i_seci i_trai i_fini i_devi i_hri i_envi i_heai i_techi i_soci
  cmp setup 
  qui xi:reg GI i.regi i.period
  
  
* Plots and descriptives

** Table 2
  bys i_seci: su surv1
  bys i_envi: su surv1
  bys i_fini: su surv1
  bys i_trai: su surv1
  bys i_devi: su surv1

** Figure 1   
  preserve
   collapse (count)iid, by(period surv1)
   reshape wide iid, i(period) j(surv1)
   twoway connected iid1 iid0 period, scheme(s1mono) ytitle("Number of IGOs") xtitle("" axis(1)) xlab(0 "1815-1944" 1 "1945-54" 2 "1955-64" 3 "1965-74" 4 "1975-84" 5 "1985-94" 6 "1995-2004" 7 "2005-14 ") legend(lab(1 "IGOs that survived") lab(2 "IGOs that dead"))
  restore

** Figure 2
graph box GIany GIno, scheme(s1mono) over(period, relabel(1 "1815-1944" 2 "1945-54" 3"1955-64" 4"1965-74" 5"1975-84" 6 "1985-94" 7 "1995-2004" 8 "2005-14 ") label(angle(90))) ytitle(Functional overlap) legend(lab(1 "Common members") lab(2 "No common members"))

** Figure A1 - membership overlap
graph box Mij, scheme(s1mono) over(period, relabel(1 "1815-1944" 2 "1945-54" 3"1955-64" 4"1965-74" 5"1975-84" 6 "1985-94" 7 "1995-2004" 8 "2005-14 ") label(angle(90))) ytitle(Membership overlap) 

** Figure A2 - functional overlap
graph box GI, scheme(s1mono) over(period, relabel(1 "1815-1944" 2 "1945-54" 3"1955-64" 4"1965-74" 5"1975-84" 6 "1985-94" 7 "1995-2004" 8 "2005-14 ") label(angle(90))) ytitle(Functional overlap) 


* Analysis

  ** Omnibus overlap
  qui probit surv1 GI _Ireg* _Iperiod*, ro
  est store a11
  qui probit surv1 GI $IA _Ireg* _Iperiod*, ro
  est store a12
  qui probit surv1 GI lnni $IA _Ireg* _Iperiod*, ro
  est store a13
  qui probit surv1 GI lnni secretariat_ind $IA _Ireg* _Iperiod*, ro
  est store a14

** Table 5  
estout a1*, title("Probit regression with robust standard errors") note("p-values: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stat(N r2_p, fmt(0 3)) 

est restore a13
margins, at(GI=(0 0.3277)) vce(uncond)


  ** Disaggregated overlap 
  qui probit surv1 GIany GIno _Ireg* _Iperiod*, ro
  est store a21
  qui probit surv1 GIany GIno $IA _Ireg* _Iperiod*, ro
  est store a22
  qui probit surv1 GIany GIno lnni $IA _Ireg* _Iperiod*, ro
  est store a23
  qui probit surv1 GIany GIno lnni secretariat_ind $IA _Ireg* _Iperiod*, ro
  est store a24
  
** Table 6  
estout a2*, title("Probit regression with robust standard errors") note("p-values: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stat(N r2_p, fmt(0 3)) 

est restore a23
margins, at(GIany=(0 0.324)) vce(uncond)


  ** Split sample by major powers and disaggregated overlap 
  qui probit surv1 GIany GIno _Ireg* _Iperiod* if majpow_ij>=0.411, ro
  est store a31
  qui probit surv1 GIany GIno lnni secretariat_ind _Ireg* _Iperiod* if majpow_ij>=0.411, ro
  est store a32
  qui probit surv1 GIany GIno _Ireg* _Iperiod* if majpow_ij<0.411, ro
  est store a33
  qui probit surv1 GIany GIno lnni secretariat_ind _Ireg* _Iperiod* if majpow_ij<0.411, ro
  est store a34
  
** Table 7  
estout a3*, title("Probit regression with robust standard errors") note("p-values: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stat(N r2_p, fmt(0 3)) 
    

* Descriptive statistics

  qui estpost su surv1 surv2 lifetime GI GIany GIno lnni secretariat_ind g7_ij 

** Table A2  
esttab ., cells("count mean sd min max") noobs


* Robustness tests 
  
  ** Zombyism 
  qui reg anyzombie c.GI##MAJP, ro
  est store r11
  qui reg anyzombie c.GI##MAJP _Ireg* _Iperiod*, ro
  est store r12
  qui reg anyzombie c.GI##MAJP lnni secretariat_ind _Ireg* _Iperiod*, ro
  est store r13
  
** Table A5  
estout r1*, title("Probit regression with robust standard errors") note("p-values: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_* 0.*) stat(N r2, fmt(0 3)) 
 
  
  ** Alternative IGO outcomes
  mat R2=J(3,3,0)
  qui cmp (surv1=GIany GIno _Ireg* _Iperiod*) (replaced=GIany GIno _Ireg* _Iper*) (integrated=GIany GIno _Ireg* _Iper*), indicators(1 1 1) ro iterate(50)
   est store r21
   qui reg surv1 GIany GIno _Ireg* _Iperiod*
   mat R2[1,1]=e(r2)
   qui reg replaced GIany GIno _Ireg* _Iperiod*
   mat R2[2,1]=e(r2)
   qui reg integrated GIany GIno _Ireg* _Iperiod*
   mat R2[3,1]=e(r2)
   
  qui cmp (surv1=GIany GIno $IA lnni _Ireg* _Iperiod*) (replaced=GIany GIno $IA lnni _Ireg* _Iper*) (integrated=GIany GIno $IA lnni _Ireg* _Iper*), indicators(1 1 1) ro iterate(50)
   est store r22
   qui reg surv1 GIany GIno _Ireg* _Iperiod* $IA lnni
   mat R2[1,2]=e(r2)
   qui reg replaced GIany GIno _Ireg* _Iperiod* $IA lnni
   mat R2[2,2]=e(r2)
   qui reg integrated GIany GIno _Ireg* _Iperiod* $IA lnni
   mat R2[3,2]=e(r2)
   
  qui cmp (surv1=GIany GIno $IA lnni secretariat_ind _Ireg* _Iperiod*) (replaced=GIany GIno lnni $IA secretariat_ind _Ireg* _Iper*) (integrated=GIany GIno lnni $IA secretariat_ind _Ireg* _Iper*), indicators(1 1 1) ro iterate(50)
   est store r23
   qui reg surv1 GIany GIno _Ireg* _Iperiod* $IA lnni secretariat_ind
   mat R2[1,3]=e(r2) 
   qui reg replaced GIany GIno _Ireg* _Iperiod* $IA lnni secretariat_ind
   mat R2[2,3]=e(r2)
   qui reg integrated GIany GIno _Ireg* _Iperiod* $IA lnni secretariat_ind
   mat R2[3,3]=e(r2)

** Table A6    
estout r2*, title("SUR regression with robust standard errors") note("p-values: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stat(N1 N2 N3, fmt(0 0 0)) 
mat li R2    


  ** Alternative survival measure (COW definition)
  qui probit surv2 GI _Ireg* _Iperiod*, ro
  est store r31
  qui probit surv2 GI $IA lnni _Ireg* _Iperiod*, ro
  est store r32
  qui probit surv2 GI $IA lnni secretariat_ind _Ireg* _Iperiod*, ro
  est store r33
  
** Table A7  
estout r3*, title("Probit regression with robust standard errors") note("p-values: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stat(N r2_p, fmt(0 3)) 
  
  
  ** Alternative outcome indicator and disaggregated analysis
  qui probit surv2 GIany GIno _Ireg* _Iperiod*, ro
  est store r41
  qui probit surv2 GIany GIno $IA lnni _Ireg* _Iperiod*, ro
  est store r42
  qui probit surv2 GIany GIno $IA lnni secretariat_ind _Ireg* _Iperiod*, ro
  est store r43
  
** Table A8  
estout r4*, title("Probit regression with robust standard errors") note("p-values: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stat(N r2_p, fmt(0 3)) 
  

  ** Lifetime of IGOs
  mat M=J(4,3,0)
  qui cmp (death=GI _Ireg* _Iperiod*) (lifetime=GI _Ireg* _Iperiod*), indicators(1 death) ro 
  est store r51
  qui reg death GI _Ireg* _Iperio*
  mat M[1,1]=e(N)
  mat M[2,1]=e(r2)
  qui reg lifetime GI _Ireg* _Iperio* if death==1
  mat M[3,1]=e(N)
  mat M[4,1]=e(r2)
  
  qui cmp (death=GI $IA lnni _Iperiod* _Ireg*) (lifetime=GI $IA lnni _Iperiod* _Ireg*), indicators(1 death) ro difficult iterate(50)
  est store r52
  qui reg death GI _Ireg* _Iperio* $IA lnni
  mat M[1,2]=e(N)
  mat M[2,2]=e(r2)
  qui reg lifetime GI _Ireg* _Iperio* $IA lnni if death==1
  mat M[3,2]=e(N)
  mat M[4,2]=e(r2)
  
  qui cmp (death=GI secretariat_ind lnni _Iperiod* _Ireg* $IA) (lifetime=GI secretariat_ind lnni _Iperiod* _Ireg* $IA), indicators(1 death) ro difficult iterate(50) 
  est store r53
  qui reg death GI _Ireg* _Iperio* $IA lnni secretariat_ind
  mat M[1,3]=e(N)
  mat M[2,3]=e(r2)
  qui reg lifetime GI _Ireg* _Iperio* $IA lnni secretariat_ind if death==1
  mat M[3,3]=e(N)
  mat M[4,3]=e(r2)
  
** Table A9  
estout r5*, title("Probit regression with robust standard errors") note("p-values: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_cons _*) stat(N r2_p, fmt(0 3)) order(GI*)
mat li M
  
est restore r52
su GI if e(sample)
di 58.8*0.3277
  
  
  ** Other IGO outcomes 
  mat M=J(4,3,0)
  qui cmp (death=GIany GIno _Ireg* _Iperiod*) (lifetime=GIany GIno _Ireg* _Iperiod*), indicators(1 death) ro 
  est store r61
  qui reg death GIany GIno _Ireg* _Iperio*
  mat M[1,1]=e(N)
  mat M[2,1]=e(r2)
  qui reg lifetime GIany GIno _Ireg* _Iperio* if death==1
  mat M[3,1]=e(N)
  mat M[4,1]=e(r2)
  
  qui cmp (death=GIany GIno $IA lnni _Iperiod* _Ireg*) (lifetime=GIany GIno $IA lnni _Iperiod* _Ireg*), indicators(1 death) ro difficult iterate(50)
  est store r62
  qui reg death GIany GIno _Ireg* _Iperio* $IA lnni
  mat M[1,2]=e(N)
  mat M[2,2]=e(r2)
  qui reg lifetime GIany GIno _Ireg* _Iperio* $IA lnni if death==1
  mat M[3,2]=e(N)
  mat M[4,2]=e(r2)
  
  qui cmp (death=GIany GIno secretariat_ind lnni _Iperiod* _Ireg* $IA) (lifetime=GIany GIno secretariat_ind lnni _Iperiod* _Ireg* $IA), indicators(1 death) ro difficult iterate(50) tech(dfp nr)
  est store r63
  qui reg death GIany GIno _Ireg* _Iperio* $IA lnni secretariat_ind
  mat M[1,3]=e(N)
  mat M[2,3]=e(r2)
  qui reg lifetime GIany GIno _Ireg* _Iperio* $IA lnni secretariat_ind if death==1
  mat M[3,3]=e(N)
  mat M[4,3]=e(r2)
  
** Table A10  
estout r6*, title("Probit regression with robust standard errors") note("p-values: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_cons _*) stat(N r2_p, fmt(0 3)) order(GI*)
mat li M
  
est restore r62
su GIany if e(sample)
di 58.8*0.3277


  ** Split sample
  qui probit surv1 GIany GIno _Ireg* _Iperiod* if g7_ij>=0.2585, ro
  est store r71
  qui probit surv1 GIany GIno lnni secretariat_ind _Ireg* _Iperiod* if g7_ij>=0.2585, ro
  est store r72
  qui probit surv1 GIany GIno _Ireg* _Iperiod* if g7_ij<0.2585, ro
  est store r73
  qui probit surv1 GIany GIno lnni secretariat_ind _Ireg* _Iperiod* if g7_ij<0.2585, ro
  est store r74

** Table A11  
estout r7*, title("Probit regression with robust standard errors") note("p-values: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stat(N r2_p, fmt(0 3)) 


  ** Zombyism 
  qui reg anyzombie c.GI##G7, ro
  est store r81
  qui reg anyzombie c.GI##G7 _Ireg* _Iperiod*, ro
  est store r82
  qui reg anyzombie c.GI##G7 lnni secretariat_ind _Ireg* _Iperiod*, ro
  est store r83
  
** Table A12  
estout r8*, title("Probit regression with robust standard errors") note("p-values: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_* 0.*) stat(N r2, fmt(0 3)) 


 ** Remove on issue area
 foreach I in sec tra fin dev hr env hea tech{
  qui probit surv1 GI lnni secretariat_ind $IA _Ireg* _Iperiod* if i_`I'i==0, ro
  est store loo`I'
  }

** Figure A4   
estout loo*, title("Probit regression with robust standard errors") note("p-values: * 10%  ** 5%  *** 1%") starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_*) stat(N r2_p, fmt(0 3)) 
coefplot loo*, keep(GI) scheme(s1mono) legend(off)
